package com.design.builder;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 自行车包
 * @author ytj
 * @date 2024/11/27 14:37
 */
public class BicyclePackage implements IMenu{
    private List<Matter> list=new ArrayList<>();
    private BigDecimal price=new BigDecimal(0);

    private String name;

    public BicyclePackage(String name){
        this.name=name;
    }

    @Override
    public IMenu appendHandle(Matter matter) {
        list.add(matter);
        price=price.add(matter.price());
        return this;
    }

    @Override
    public IMenu appendBody(Matter matter) {
        list.add(matter);
        price=price.add(matter.price());
        return this;
    }

    @Override
    public IMenu appendWheel(Matter matter) {
        list.add(matter);
        price=price.add(matter.price());
        return this;
    }

    @Override
    public void getDetail() {
        System.out.println("--------------------------------------------");
        System.out.println("自行车名称:"+name);
        System.out.println("自行车价格:"+price);
        for (Matter matter : list) {
            System.out.println(matter.grade()+matter.name()+"，价格:"+matter.price());
        }
    }
}
